require("./../../js/select2/select2.min.js");
require("./../../js/select2/i18n/zh-CN.js");
require("./../../js/fontIconPicker/jquery.fonticonpicker.min.js");
require("./../../js/bootstrap-switch/bootstrap-switch.js");

import $ from 'jquery';
global.$ = global.jQuery = $;

(function ($) {
    $('.select2').select2({ "size": "mini", "allowClear": true });
    $("input[data-bootstrap-switch]").each(function () {
        $(this).bootstrapSwitch('state', $(this).prop('checked'));
    });
    var selectPId = $("input[name='parentIdSelect']").val();
    $("select[name='parent_id']").val(selectPId).trigger("change");
    var selectUri = $("input[name='uriSelect']").val();
    $("select[name='uri']").val(selectUri).trigger("change");
    var font_element = $('#icon').fontIconPicker({ theme: 'fip-bootstrap' });
    $.ajax({ url: '/images/materialdesignicons_v4.json', type: 'GET', dataType: 'json' }).done(function (response) {
        var fontello_json_icons = [];
        $.each(response.glyphs, function (i, v) {
            fontello_json_icons.push(v.css);
        });
        font_element.setIcons(fontello_json_icons);
    }).fail(function () {
        console.error('字体图标配置加载失败');
    });
})(jQuery);
